package com.zjy.heath_ms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mysql.jdbc.StringUtils;
import com.zjy.heath_ms.entity.QueryPageBean;
import com.zjy.heath_ms.mapper.CheckItemMapper;
import com.zjy.heath_ms.pojo.CheckItem;
import com.zjy.heath_ms.service.CheckItemService;
import org.springframework.stereotype.Service;

/**
 * 项目名 heath_ms
 * 类名  CheckItemServiceImpl
 * 作者 lzq
 * 创建时间  2025/5/25 12:49
 */

@Service
public class CheckItemServiceImpl extends ServiceImpl<CheckItemMapper, CheckItem> implements CheckItemService {
    @Override
    public Page<CheckItem> findPage(QueryPageBean queryPageBean) {
        // 查询条件
        LambdaQueryWrapper<CheckItem> checkItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
        String queryString = queryPageBean.getQueryString();
        if (!StringUtils.isNullOrEmpty(queryString)) {
            checkItemLambdaQueryWrapper.like(CheckItem::getCode, queryString)
                    .or()
                    .like(CheckItem::getName, queryString);
        }
        // 分页条件
        Page<CheckItem> checkItemPage = new Page<>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        // 分页查询
        baseMapper.selectPage(checkItemPage, checkItemLambdaQueryWrapper);
        return checkItemPage;
    }
}
